<?php
class URecordBehavior extends CActiveRecordBehavior
{
    public $createUserAttribute;
    public $updateUserAttribute;

    public function beforeSave($event)
    {
        if($this->owner->isNewRecord && $this->createUserAttribute !== null)
        {
            $this->owner->setAttribute($this->createUserAttribute,Yii::app()->user->id);
        }
        if(!$this->owner->isNewRecord && ($this->updateUserAttribute !== null))
        {
            $this->owner->setAttribute($this->updateUserAttribute,Yii::app()->user->id);
        }
        parent::beforeSave($event);
    }

}